<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box>input{
            width: 80px;
            height: 30px;
        }
        #box>div{
            width: 300px;
            height: 200px;
            border:1px solid red;
            text-align: center;
            line-height: 200px;
            display: none;
        }
        #box>input.active{
            background: blue;
            color: white;
        }
        #box>div.active{
            display: block;
        }
    </style>
    <script>
        window.onload = function () {
            var oT = new Tab('#box');
            oT.init();
        }

        function Tab(id) {
            this.oDiv = document.querySelector(id);
            this.aBtn = this.oDiv.querySelectorAll('input');
            this.aDiv = this.oDiv.querySelectorAll('div');
        }
        Tab.prototype.init = function () {
            for(var i=0;i<this.aBtn.length;i++){
                this.aBtn[i].index = i;
                var This = this;
                this.aBtn[i].onclick = function () {
                    This.changeTab(this)
                }
            }
        }

        Tab.prototype.changeTab = function(oBtn){
            for(var i=0;i<this.aBtn.length;i++){
                this.aBtn[i].className = "";
                this.aDiv[i].style.display = "none";
            }
            oBtn.className = "active";
            this.aDiv[oBtn.index].style.display = "block";
        }
    </script>
</head>
<body>
    <div id="box">
        <input type="button" value="按钮1" class="active">
        <input type="button" value="按钮2">
        <input type="button" value="按钮3">
        <div class="active">内容一</div>
        <div>内容二</div>
        <div>内容三</div>
    </div>
</body>
</html>